$(function () {
    fandDailyByName(localStorage.getItem("username"));
})
function fandDailyByName(username) {
    $("#userName").val(username);
    let data=myAjax("/daily/fandDailyByName",{userName:username},"post");
        data=data.data.state;
        if (data==0){
            $("#dailyState").html("未提交");
        }else if (data==1){
            $("#dailyState").html("已提交");
        }else if (data==2){
            $("#dailyState").html("已查看");
        }else if (data==3){
            let html="<a href=\"javascript:$('#middle-reght').load('daily/dailyUpdate.html')\">草稿</a>"
            $("#dailyState").html(html);
        }
}

function dailyAdd(state) {
    let da={
        dailyType:$("#dailyType").val(),
        userName:$("#userName").val(),
        submissionDate:$("#submissionDate").val(),
        major:$("#major").val(),
        coach:$("#coach").val(),
        supervision:$("#supervision").val(),
        learningContent:$("#learningContent").val(),
        harvest:$("#harvest").val(),
        insufficient:$("#insufficient").val(),
        opinion:$("#opinion").val(),
        state:state,
    }
    let data=myAjax("/daily/myDailyAdd",da,"post");
    if (data.data==1){
        alert("提交成功");
        $('#middle-reght').load('daily/myDailyFind.html');
    }if (data.data==2){
        alert("今日已提交");
        $('#middle-reght').load('daily/myDailyFind.html');
    }else if (data.code==500){
        alert("提交失败");
    }
}